#!/bin/sh
apt-get -y install pptpd
vpsip=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk 'NR==1 { print $1}'`

cat >>/etc/pptpd.conf<<EOF
localip 192.168.10.1
remoteip 192.168.10.2-199
EOF

cat >>/etc/ppp/pptpd-options<<EOF
ms-dns 8.8.8.8
ms-dns 8.8.4.4
EOF

sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
sysctl -p

sed -i 's/exit 0//g' /etc/rc.local

iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -o eth0 -j MASQUERADE
iptables -A FORWARD -s 192.168.10/24 -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1390

cat >>/etc/rc.local<<EOF
iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -o eth0 -j MASQUERADE
iptables -A FORWARD -s 192.168.10/24 -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1390
exit 0
EOF

service pptpd restart
